
#include "stdafx.h"
#include "Server.h"
#include "Customer.h"
#pragma once;
using namespace std;

class ServerRenting
{
private:

public:
	static ResultInfo* rentServer(SendInfo info)
	{
		Server* server = Server::seekIdleServer();
		if(server != NULL && Customer::login(info.userName,info.passWord))
		{
			ResultInfo* result = new ResultInfo();
			result->serverName = server->getServerName();
			result->thoiGianXuLy = server->caculateProcessTime(info.doPhucTap);
			result->giaTien = server->cauculatePrice(result->thoiGianXuLy);

			return result;
		}
		return  NULL;
	}

	static ResultInfo* rentSuperServer(SendInfo info)
	{
		Server* server = Server::seekIdleSuperServer();
		if(server != NULL && Customer::login(info.userName,info.passWord))
		{
			ResultInfo* result = new ResultInfo();
			result->serverName = server->getServerName();
			result->thoiGianXuLy = server->caculateProcessTime(info.doPhucTap);
			result->giaTien = server->cauculatePrice(result->thoiGianXuLy);

			return result;
		}
		return  NULL;
	}
}